DROP PROCEDURE IF EXISTS CREATE_VIEW;
DELIMITER $$

CREATE PROCEDURE CREATE_VIEW()
BEGIN
<#list ViewMySQL as v>
    BEGIN
    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
    BEGIN
    GET CURRENT DIAGNOSTICS CONDITION 1 @errno = MYSQL_ERRNO, @msg = MESSAGE_TEXT;
    select @errno,@msg;
    END;
    IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '${v.name}')
    THEN
    <#if v.getMySQL()??>

        ${v.getMySQL()};
    </#if>
    END IF;
    END;
</#list>
END;
CALL CREATE_VIEW;
DROP PROCEDURE CREATE_VIEW;

$$